#ifndef QWIDGETVIEW_H
#define QWIDGETVIEW_H

#include <QTreeWidget>
#include <QMap>

namespace SHAREDLIB
{
    class QAbstractHost;
}

namespace CORELIB
{
    enum  FIND_POINT
    {
        FP_NEXT,
        FP_PREV
    };
    class QWidgetView : public QTreeWidget
    {
        Q_OBJECT
    public:
        explicit QWidgetView(SHAREDLIB::QAbstractHost* host,QWidget *parent = 0);
        void    setSelect(SHAREDLIB::QAbstractHost *host);
        SHAREDLIB::QAbstractHost *currentHost();
    protected:
        void    initWidgetList();
        void    find(QTreeWidgetItem *start,QTreeWidgetItem *item,const QString &text,FIND_POINT fp);
        void    drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const;
        void    setSelected(QTreeWidgetItem *item);
    signals:
        void    select(SHAREDLIB::QAbstractHost* host);
    public slots:
        void    clickedItem(QTreeWidgetItem *item,int col);
        void    findNext(const QString &text);
        void    findPrev(const QString &text);
    protected:
        QMap<SHAREDLIB::QAbstractHost*,QTreeWidgetItem*>   m_items;
        SHAREDLIB::QAbstractHost                           *m_property_host;
    };

}

#endif // QWIDGETVIEW_H
